package com.jone.bang.util;

import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import com.jone.bang.model.WordItem;



public class XmlParseUtil {
	
	public static final String TAG = "XmlParseUtil";
	
	@SuppressWarnings("unchecked")
	public static  String dom4jParse(String content){
		if(content == null || "".equals(content)){
			return null;
		}
		StringBuffer sb = new StringBuffer();
		SAXReader saxReader = new SAXReader();  
		Document document;  
		 try{			
			 document = saxReader.read(new ByteArrayInputStream(content.getBytes()));  
			
			 Element root = document.getRootElement();// 得到根节点
             int row = 0;
             
           //遍历根结点的所有孩子节点tr
     		for (Iterator iter = root.elementIterator(); iter.hasNext();) {
     			Element element = (Element) iter.next();
     			row++;
     			int tdRow = 0;
     			String line = "";
     			//遍历所有孩子节点,并进行处理td
     			for (Iterator iterInner = element.elementIterator(); iterInner.hasNext();) {
     				tdRow++;	
     				if(tdRow>3){
     					break;
     				}else{
     					Element name = (Element) iterInner.next();     					
     				
     					if(tdRow==2){
     						line = name.getText();
     					}
     				}	     				
     			}
     			sb.append(line).append("\n");
     		}
             
		 }catch(Exception e){
		 }	
		 return sb.toString();
	}
	
	
	
	
	
}